﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;

namespace BTCairo
{
    public class BasicText : BasicShape
    {
        int x;
        int y;
        string text;
        int size;
        public BasicText(CommonGraphics g, int _x, int _y, string txt, int s)
        {
            CommonGraphics = g;
            InfoGraphic = g.MyInfoGraphic;
            x = _x;
            y = _y;
            text = txt;
            size = s;
        }
        public override void Draw()
        {
            CommonGraphics.DrawText(text, size, x, y);
        }

        public override void ParseXmlElement(System.Xml.XmlDocument doc, System.Xml.XmlElement root)
        {
            //<text x="0" y="15" fill="red" font-size="20" font-weight="bold">I love SVG</text>
            XmlElement node = doc.CreateElement("text");
            node.SetAttribute("x", x.ToString());
            node.SetAttribute("y", y.ToString());
            node.SetAttribute("fill", "black");
            node.SetAttribute("font-size", size.ToString());
            node.SetAttribute("font-weight", "bold");
            node.InnerText = text;
            root.AppendChild(node);
        }
    }
}
